{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 24)\n"
     ]
    }
   ],
   "source": [
    "def demo(s):\n",
    "    result=[0,0]\n",
    "    for ch in s:\n",
    "        if ch.islower():               #当前字符为小写字母\n",
    "            result[1]+=1               #小写字母个数+1\n",
    "        elif ch.isupper():             #当前字符为大写字母\n",
    "           result[0]+=1                #大写字母个数+1\n",
    "    return tuple(result)\n",
    "\n",
    "print(demo('Beautiful is better than ugly.'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1]\n",
      "[1, 1]\n",
      "[1, 2, 1]\n",
      "[1, 3, 3, 1]\n",
      "[1, 4, 6, 4, 1]\n",
      "[1, 5, 10, 10, 5, 1]\n"
     ]
    }
   ],
   "source": [
    "def yanghui(t):\n",
    "    print([1])                               #输出第一行\n",
    "    line=[1,1]\n",
    "    print(line)                              #输出第二行\n",
    "    for i in range(2,t):\n",
    "         r=[]                                #存储当前行除两端之外的数字\n",
    "         for j in range(0,len(line)-1):\n",
    "             r.append(line[j]+line[j+1])     #第i行出两端之外其他的数字\n",
    "         line=[1]+r+[1]                      #第i行的全部数字   \n",
    "         print(line)                         #输出第i行\n",
    "yanghui(6)\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
